<template>
	<view>
		<view class="robotMessage"  v-if="item.leftStatus &&  item.type == 'select'" > <!-- :class="{'item-hide':  !(item.leftStatus &&  item.type == 'select')}"  > -->
			<image class="image" src="/static/img/robot.png" mode=""></image>
			<view class="doublec">  
				<uni-list>
					<uni-list-item v-for="(m , i) in item.list"  class="list-item"   :key="i" :showArrow="true" :title="removeBetweenAtSymbols(m.problemAbstract)" :clickable="false"   link="navigateTo"
						 @tap="showInfo(m.problemResult,m.problemAbstract,m.id,m.detailType)"  :customStyle="{titleFontSize:'18rpx',titleFontColor:'#787878'}"
					 ></uni-list-item>
				</uni-list>
				<text class="load-more" v-if="item.list != undefined && item.list.length >= 5"  @tap="loadMore(item.list[0].sendMessage,item.list[0].problemTable)">点击查看更多</text>
			</view> 
		</view>
	</view>
</template>

<script>
	export default {
		name:"rebotSelectMessage",
		props:{
			item:{
				type:Object,
				require:true,
				default:{}
			},
		},
		data() {
			return {
				
			};
		},
		methods:{
			showInfo(problemResult,problemAbstract,id,detailType) {
				//查看消息详情信息 
				if(detailType == 'text'){ 
					uni.navigateTo({
						url:'/pages/robot/messageInfo',
						success: (res) => {
							res.eventChannel.emit('updatePageData',{ data:'', title: problemAbstract ,content: problemResult })
						}
					})
				} else if(detailType == 'page'){
					//提取消息跳转页面 截取两个@@之间的跳转路径信息
					let  pagePath = this.extractBetweenAtSymbols(problemResult);
					uni.navigateTo({
						url: pagePath + '&detail=true' 
					})
				}
			},
			extractBetweenAtSymbols(str) {
				if(str == null ){
					return str;
				}
				const match = str.match(/@(.*?)@/);
				return match ? match[1] : str;
			},
			removeBetweenAtSymbols(str) {
				if(str == null ){
					return str;
				} 
				return str.replace(/@.*?@/g, '');
			},
			loadMore(message,tableName){ 
				const that = this; 
				uni.navigateTo({
					url:'/pages/robot/loadMoreList',
				  success: function(res) {
					// 通过eventChannel向被打开页面传送数据
					res.eventChannel.emit('loadData', { content: message ,tableName:tableName ,companyId:that.companyId })
				  }
				})
				
			}
		}
	}
</script>

<style lang="scss">
.robotMessage {
		display: flex;
		align-items: flex-start;
		flex-direction: row;
		justify-content: flex-start;
		
		.image {
			width: 59rpx;
			height: 50rpx;
			margin: 0 14rpx 0 0;
		}
		
	}
	.doublec {
		margin: 0;
		border-radius: 14rpx;
		background-color: white;
		border: 2rpx solid rgba(187, 187, 187, 0.5294117647);
		padding: 10 30rpx;
		margin-bottom: 30rpx;
		max-width: 600rpx;
		// max-width: 600rpx;
		/* overflow: hidden; */

		.left-message {
			font-size: 18rpx;
			font-family: AppleColorEmoji;
			color: #000;
			white-space: nowrap;
			text-overflow: ellipsis;
			max-width: 500rpx;
			margin: 0;
			border-radius: 14rpx;
			/* overflow: hidden; */
		}
	}
	
	.load-more{
		font-size: 16rpx;
		color: '#c6c6c6';
		text-align: center;
		padding: 10px 0px;
	}
</style>